package game;
import gui.components.Dialogable;

import java.awt.Point;
import java.util.ArrayList;

import javax.swing.*;
public class GameField extends JLabel implements Dialogable{
	public static final int NORMAL=0;
	public static final int COMMUNITY_CHEST=1;
	public static final int TAX=2;
	public static final int CHANCE=3;
	public static final int AIRPORT=4;
	public static final int START=5;
	public static final int FREE_PARKING=6;
	public static final int JAIL=7;
	public static final int TO_JAIL=8;
	public static final int COMMUNICATION=9;
	public static final int DOWN=10;
	public static final int UP=11;
	public static final int LEFT=12;
	public static final int RIGHT=13;
	
	private ImageIcon icon;
	private String name;
	private PlayerDAO owner;
	private int type;
	private int orientation;
	private int cost;
	
	
	public GameField(String imageName, int fieldType, int fieldOrientation, int inCost){
		icon = new ImageIcon(imageName);
		this.setIcon(icon);
		this.orientation=fieldOrientation;
		this.name=imageName.substring(0, imageName.indexOf("."));
		if(this.name.lastIndexOf("/")!=-1){
			this.name = this.name.substring(name.lastIndexOf("/")+1);
		}
		this.type= fieldType;
		owner= null;
		cost = inCost;
		
	}
	
	
	/**
	 * <p><p>
	 * <b> getCenter</b><p>
	 * {@code public} {@link Point} <b>getCenter()</b><p> 
	 * get the center of a gamefield
	 * @return returns the center as a {@link Point}
	 */
	public Point getCenter(){
		return new Point (
				this.getX()+(this.getWidth()/2),
				this.getY()+(this.getHeight()/2)
				);
	}


	public ImageIcon getIcon(){
		return icon;
	}
	
	public int getType() {
		return type;
	}


	public int getOrientation() {
		return orientation;
	}

	public int getCost(){
		return cost;
	}

	public PlayerDAO getOwner() {
		return owner;
	}


	public void setOwner(PlayerDAO owner) {
		this.owner = owner;
	}
	
	public String getName(){
		return name;
	}
}
